package com.dc.project.entity.vo;

import com.dc.project.entity.po.TaskFileCommit;
import com.own.business.resource.entity.vo.FileRecordVo;
import com.own.component.common.base.entity.vo.BaseVo;
import com.own.constant.ConstantBeanSuffix;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * TaskFileCommitVo
 *
 * @author chenxueli
 * @date 2025-03-10 16:37:53
 */
@Schema(title = "任务文件提交" + ConstantBeanSuffix.VO)
@Getter
@Setter
@ToString
@Accessors(chain = true)
@AllArgsConstructor
@NoArgsConstructor
public class TaskFileCommitVo extends BaseVo<TaskFileCommit> implements Serializable {

    @Schema(title = "任务id")
    private Long taskId;

    @Schema(title = "详情id")
    private Long detailId;

    @Schema(title = "项目id")
    private Long itemId;

    @Schema(title = "父级提交id")
    private Long parentCommitId;

    @Schema(title = "上传的附件id")
    private Long fileId;

    @Schema(title = "上传的附件路径")
    private String filePath;

    @Schema(title = "提交类型 1=task 2=detail 3=item")
    private Integer type;

    @Schema(title = "提交的目标id")
    private Long targetId;

    @Schema(title = "解析状态 1=等待执行中 2=解析文本中 3=解析完成，压缩内容中 4=处理完成 5=解析失败 6=压缩内容失败 7=处理失败")
    private Integer status;

    @Schema(title = "解析消息")
    private String parseMessage;

    @Schema(title = "附件信息")
    private FileRecordVo fileRecord;

    @Schema(title = "资料所属年份")
    private String year;

    @Schema(title = "资料所属类别")
    private String category;

    @Schema(title = "序号")
    private Integer sortOrder;

    @Schema(title = "子文件列表")
    private List<TaskFileCommitVo> children = new ArrayList<>();

    /**
     * 构造方法
     *
     * @param entity 原对象
     */
    public TaskFileCommitVo(@NonNull TaskFileCommit entity) {
        super(entity);
        this.taskId = entity.getFkTaskId();
        this.detailId = entity.getFkDetailId();
        this.itemId = entity.getFkItemId();
        this.fileId = entity.getFkFileId();
        this.filePath = entity.getFilePath();
        this.type = entity.getType();
        this.targetId = entity.getFkTargetId();
        this.status = entity.getStatus();
        this.parseMessage = entity.getParseMessage();
        this.year = entity.getYear();
        this.category = entity.getCategory();
        this.sortOrder = entity.getSortOrder();
        this.parentCommitId = entity.getFkParentCommitId();
    }

    /**
     * 转po对象
     *
     * @param entity 原对象
     * @return po对象
     */
    @Override
    public TaskFileCommit toPo(TaskFileCommit entity) {
        if (entity == null) {
            entity = new TaskFileCommit();
        }
        entity.setFkTaskId(this.taskId);
        entity.setFkDetailId(this.detailId);
        entity.setFkItemId(this.itemId);
        entity.setFkFileId(this.fileId);
        entity.setFilePath(this.filePath);
        entity.setType(this.type);
        entity.setFkTargetId(this.targetId);
        entity.setStatus(this.status);
        entity.setParseMessage(this.parseMessage);
        entity.setYear(this.year);
        entity.setCategory(this.category);
        entity.setSortOrder(this.sortOrder);
        entity.setFkParentCommitId(this.parentCommitId);
        return super.toPo(entity);
    }

}
